using System.Collections.Generic;
using System.IO;


namespace Pronghorn.Core
{
	public class ScriptRenderer : IFileLinkRenderer
	{
		private readonly SiteContext _siteContext;

		public ScriptRenderer(SiteContext siteContext)
		{
			_siteContext = siteContext;
		}

		public void Render(IList<string> scripts, TextWriter writer)
		{
			if (scripts.Count == 0) return;
			writer.Write("<script type=\"text/javascript\" src=\"scripts/js/");
			foreach (var script in scripts)
			{
				writer.Write(script);
				writer.Write("|");
			}

			writer.Write("&version=");
			writer.Write(_siteContext.JsVersion);
			writer.Write("\"></script>\r\n");
		}
	}
}